export default {
    data() {
      return {
        spinShow: false,
        VIRTUAL_PATH: process.env.VUE_APP_VIRTUAL_PATH,
        uploadUrl: process.env.VUE_APP_API_ROOT+ "/excel",
        currentStep: 0,
        excelTableData: [],
        excelTablCol: [
          {
            title: "书名",
            key: "书名",
            align: "center",
            width: 200,
            fixed: 'left'
          },
          {
            title: "出版社",
            key: "出版社",
            align: "center",
            width: 100,
          },
          {
            title: "出版年份",
            key: "出版年份",
            align: "center",
            width: 100,
          },
          {
            title: "出版月份",
            key: "出版月份",
            align: "center",
            width: 100,
          },
          {
            title: "原著",
            key: "原著",
            align: "center",
            width: 100,
          },
          {
            title: "编者",
            key: "编者",
            align: "center",
            width: 100,
          },
          {
            title: "绘画",
            key: "绘画",
            align: "center",
            width: 100,
          },
  
          {
            title: "封面",
            key: "封面",
            align: "center",
            width: 100,
          },
          {
            title: "印数",
            key: "印数",
            align: "center",
            width: 100,
          },
          {
            title: "定价",
            key: "定价",
            align: "center",
            width: 100,
          },
          {
            title: "页数",
            key: "页数",
            align: "center",
            width: 100,
          },
          {
            title: "开本",
            key: "开本",
            align: "center",
            width: 100,
          },
          {
            title: "版次信息",
            key: "版次信息",
            align: "center",
            width: 100,
          },
          {
            title: "备注",
            key: "mark",
            slot: "mark",
            width:200,
            align: "center",
            fixed:"right"
          },
        ],
        resultType: "1",
        list: [],
      };
    },
    methods: {
      uploadExcelSuccess(res, file, fileList) {
        this.excelTableData = res.data;
        this.list = this.excelTableData
        this.currentStep = 2;
      },
      resultchange(value) {
        switch (value) {
          case "1":
            this.list = this.excelTableData.list;
            break;
          case "2":
            this.list = this.excelTableData.success;
            break;
  
          case "3":
            this.list = this.excelTableData.error;
            break;
        }
      },
      imporExcelData() {
        this.spinShow = true;
        if (this.excelTableData.length == 0) {
          this.$Message.warning("请先导入数据");
          this.spinShow = false;
          return;
        }
        //
      ;
        // let formdata = new FormData();
        // formdata.append("list", JSON.stringify(this.excelTableData));
        this.$axios({
          url: "/api/book/list",
          method: "PUT",
          data: this.excelTableData,
        })
          .then((res) => {
            if (res.code == 200) {
              this.excelTableData = res.data;
              this.list = this.excelTableData.list;
              // this.getData();
              this.$emit("success", "");
            } else {
              this.$Message.error(res.msg);
            }
            this.spinShow = false;
          })
          .catch((error) => {
            this.spinShow = false;
            this.$Message.error(error.message);
          });
      },
    },
  };
  